package pcsr.simulator.ui;

import javax.swing.JPanel;

import java.awt.Color;
import java.awt.Dimension;
import java.util.ArrayList;

public class SimulationField extends JPanel {

	private static final long serialVersionUID = -8800094286406511750L;
	
	private ArrayList<SimulatorWall> mywalls = new ArrayList<SimulatorWall>();
	private ArrayList<SimulatorEmitter> myemitters = new ArrayList<SimulatorEmitter>(); 
	
	/**
	 * This method initializes 
	 * 
	 */
	public SimulationField() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 */
	private void initialize() {
        this.setPreferredSize(new Dimension(400, 400));
        this.setMaximumSize(this.getPreferredSize());
        this.setLayout(null);
		this.setBackground(new Color(1f, 1f, 1f, 1f));
		
	}

	public void setWalls(ArrayList<SimulatorWall> newWalls) {
		mywalls.clear();
		mywalls.addAll(newWalls);
		repopulateField();
	}

	/**
	 * 
	 */
	private void repopulateField() {
		this.removeAll();
		for(SimulatorWall sw : mywalls)
		{			
			this.add(sw);
		}
		for(SimulatorEmitter se : myemitters)
		{			
			this.add(se);
		}
	}

	public void setEmitters(ArrayList<SimulatorEmitter> newEmitters) {		
		myemitters.clear();
		myemitters.addAll(newEmitters);
		repopulateField();		
	}

}
